# -*- coding: utf-8 -*-
__author__ = 'yanshi'
import urllib2
import re
from com.umessage.bean import proxy_site
from com.umessage.db.db_utils import DBUtils

class ProxyHandler(object):
    def __init__(self):
        pass

    def loadProxy(self):
        urls = DBUtils().load_proxy_site()
        for url in urls :
            pages = url.loadPage()
            for page in pages :
                proxyPage=proxy_site.ProxyPage(1,page[0],'ip_temp',page[1],'2013-05-11')
                proxys =proxyPage.loadProxyInfo()
                for proxy in proxys:
                    proxyInfo = proxy_site.ProxyInfo(proxy[0],proxy[1],0)
                    if proxyInfo.test():
                        DBUtils().insert_proxy_ip(proxyInfo.getIp(),proxyInfo.getPort(),proxyInfo.getMS())

    def testProxy(self,url):
        pass


if __name__ == '__main__':
    pass